import { fullProvider,lazyInject,inject } from 'legions-control-container';
import { ProjectFormFieldsRule } from '../../models/form/projectFormFields';
import { LegionsProForm } from 'legions-pro-design';
import CreateProjectModule from '../../containers/project.module';
/** 初始化仓库表单配置项 */
@fullProvider(CreateProjectFormConfig)
export default class CreateProjectFormConfig {
    /** 初始化仓库表单信息 */
    createConfig(that: CreateProjectModule) {
        const rules = ProjectFormFieldsRule.createFormRules<ProjectFormFieldsRule>(ProjectFormFieldsRule,{ that });
        const formUtils = new LegionsProForm.ProFormUtils();
        formUtils.renderInputConfig({
            iAntdProps: formUtils.createAntdProps('projectSrc',null,'格式/xxx'),
            iFormProps: {
                ...formUtils.createLayout('项目存放路径',8,16),
                maxLength: '160',
            },
            rules: rules.projectSrc
        });

        formUtils.renderInputConfig({
            iAntdProps: formUtils.createAntdProps('gitUserName',null,'Git账户名'),
            iFormProps: {
                ...formUtils.createLayout('Git账户名',8,16),
                maxLength: '16',
            },
            rules: rules.gitUserName
        });
        formUtils.renderInputConfig({
            iAntdProps: formUtils.createAntdProps('branch',null,'功能分支名称'),
            iFormProps: {
                ...formUtils.createLayout('分支名称',8,16),
                maxLength: '16',
            },
            rules: rules.branch
        });
        formUtils.renderInputConfig({
            iAntdProps: formUtils.createAntdProps('gitPwd',null,'Git密码'),
            iFormProps: {
                ...formUtils.createLayout('Git密码',8,16),
                maxLength: '16',
                type: 'password',
            },
            rules: rules.gitPwd
        });
        formUtils.renderCascaderConfig({
            iAntdProps: formUtils.createAntdProps('modulesName',2,'模块'),
            iFormProps: {
                ...formUtils.createLayout('系统模块',8,16),
                options: [{
                    value: 'hoolinks-mbp-monorepo-web',
                    label: 'mbp-web',
                    children: [{
                        value: 'hoolinks-scm-web',
                        label: 'scm',
                        children: [{
                            value: 'scm-cbec',
                            label: 'cbec',
                        },
                        {
                            value: 'scm-cbec-basic',
                            label: 'cbec-basic',
                        },
                        {
                            value: 'scm-cbec-spo',
                            label: 'cbec-spo',
                        },
                        ],
                    }],
                }],
            },
            rules: rules.modulesName
        });
        formUtils.renderInputConfig({
            iAntdProps: formUtils.createAntdProps('componentName',null,'模板名称只能是英文字符，最大长度为16'),
            iFormProps: {
                ...formUtils.createLayout('模块名称',8,16),
                maxLength: '16',
                visible:false,
            },
            rules: rules.componentName
        })
        return [
            formUtils.getFormConfig('modulesName'),
            formUtils.getFormConfig('projectSrc'),
            formUtils.getFormConfig('gitUserName'),
            formUtils.getFormConfig('gitPwd'),
            formUtils.getFormConfig('branch'),
            formUtils.getFormConfig('componentName'),
        ]
    }

}